<template>
  <view class="view-bg container">
    <nav-bar ref="navBarRef" color="#ffffff" height="200rpx" title="首页"></nav-bar>

    <button type="primary" @click="toBluetooth">蓝牙</button>
    <!-- <button type="primary" @click="onClick">消息+1</button> -->

    <!-- <button type="primary" @click="onClear">清除消息</button> -->

    <button type="primary" @click="open">打开对话框</button>
    <!--    <button type="primary" @click="close">关闭对话框</button>-->
    <!--    <button type="primary" @click="setTitle">设置标题</button>-->
    <!--    <button type="primary" @click="showSubmit">显示确认按钮</button>-->
    <!--    <button type="primary" @click="showCancel">显示取消按钮</button>-->

    <version v-if="store.NODE_ENV === 'development'"></version>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad, onHide } from '@dcloudio/uni-app';
import { useStore } from '@/store';
// import { getBadgeSupport } from '@/uni_modules/badge-plugin';

const store = useStore();
// const deviceInfo = ref();
const navBarRef = ref();

onLoad(() => {
  // 获取设备信息
  // deviceInfo.value = getBadgeSupport();
  // console.log('设备信息:', deviceInfo.value);
});
onHide(() => {
  navBarRef.value.closeDialog();
});

const toBluetooth = () => {
  uni.navigateTo({
    url: '/pages/bluetooth/bluetooth'
  });
};

// 打开对话框
const open = () => {
  navBarRef.value.showDialog('对话框标题');

  setTimeout(() => {
    navBarRef.value.setTitle('新标题');
  }, 1000 * 3);

  setTimeout(() => {
    navBarRef.value.showSubmit('确认按钮');
  }, 1000 * 5);

  setTimeout(() => {
    navBarRef.value.showCancel('取消按钮');
  }, 1000 * 7);
};
</script>

<style lang="scss" scoped>
.container {
  height: 100%;
  padding: 20rpx;

  &:before {
    content: '';
    width: 100%;
    height: 200rpx;
  }
}
</style>
